package com.innovations.framework.security.handle;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

// 自定义的 UsernamePasswordAuthenticationToken 类，继承自 UsernamePasswordAuthenticationToken
public class CustomUsernamePasswordAuthenticationToken extends UsernamePasswordAuthenticationToken {

    // 自定义的额外属性，这里以一个自定义的请求 ID 为例
    private final String customRequestId;

    // 未认证时使用的构造函数
    public CustomUsernamePasswordAuthenticationToken(Object principal, Object credentials, String customRequestId) {
        super(principal, credentials);
        this.customRequestId = customRequestId;
    }

    // 已认证时使用的构造函数
    public CustomUsernamePasswordAuthenticationToken(Object principal, Object credentials,
                                                     Collection<? extends GrantedAuthority> authorities,
                                                     String customRequestId) {
        super(principal, credentials, authorities);
        this.customRequestId = customRequestId;
    }

    // 获取自定义请求 ID 的方法
    public String getCustomRequestId() {
        return customRequestId;
    }
}